# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-cymem
pkgver=2.0.7
pkgrel=2
pkgdesc="Cython memory pool for RAII-style memory management"
url="https://github.com/explosion/cymem"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('python')
makedepends=('cython' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest')
source=("https://github.com/explosion/cymem/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('45bf7d9b3b19374eb179e37e14c549aa60573a5718c14405c41b7f443ed3bef4f192936aa9cad7872052d165eee301e5a7d5a14153efc2a7162410d813b18d28')

build() {
  cd cymem-$pkgver
  python -m build --no-isolation --wheel
}

check() {
  cd cymem-$pkgver

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  python -m installer -d "tmp_install" dist/cymem-*.whl
  cd tmp_install/$site_packages
  pytest cymem
}

package() {
  cd cymem-$pkgver
  python -m installer -d "$pkgdir" dist/cymem-*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
